package com.panopset.db;

import java.io.StringWriter;

/**
 * Field ID key.  This is the primary key for all TableDescriptions.
 * @author Karl Dinwiddie
 *
 */
class FieldIdKey extends DataField {

    /**
     * bigint not null.
     */
    protected static final String INT_NOT_NULL = " bigint not null";

    /**
     * ID_NOT_NULL + auto_increment.
     */
    private static final String AUTO_INDEX = INT_NOT_NULL + " auto_increment";

    /**
     * @param name Name.
     */
    public FieldIdKey(final String name) {
        super(name);
        setIndexed();
        setPrimaryKey();
    }
    @Override
    public String getAttributes() {
        if (attrs == null) {
            StringWriter sw = new StringWriter();
            sw.append(AUTO_INDEX);
            attrs = sw.toString();
        }
        return attrs;
    }

    /**
     * Attributes.
     */
    private String attrs;
}
